<?php

namespace addons\cms\controller\api;

use addons\cms\model\Archives as ArchivesModel;
use addons\cms\model\ArchivesInteraction;
use addons\cms\model\ScoreLog;
use addons\cms\model\SocietiesSign;
use addons\third\model\Third;
use app\admin\model\cms\ActivitySign;
use app\common\model\cms\Delivery;
use app\common\model\User;
use think\Cache;
use think\Db;
use think\Exception;
use think\Validate;

/**
 * 文档
 */
class Area extends Base
{
    protected $noNeedLogin = ['area'];

    public function area()
    {
        $lang = getHeaderLang();
        $field = 'id as value,pid,name as text';
        if ($lang != getDefaultLang()){
            $field = 'id as value,pid,name_'.$lang.' as name as text';
        }
        $area_info = \app\common\model\cms\Area::where('id',3716)->field($field)->select();
        foreach ($area_info as $k => $v){
            $branch = \app\common\model\cms\Area::where('pid',$v['value'])->field($field)->select();
            foreach ($branch as $k1 => $v1){
                $v1->children = \app\common\model\cms\Area::where('pid',$v1['value'])->field($field)->select();
            }
            $v->children = $branch;
        }
        $this->success('success',$area_info);
//        $youdao = new \youdao\Youdao();
//        foreach ($area_list as $k => $v){
//            $value = $youdao->translate($v->name,'zh-CHS');
//            $v->name_zh_cn = $value;
//            $v->save();
//        }

//        $row = $this->request->post('', '', 'trim,xss_clean');
    }

}
